package day07;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.PageContext;
import javax.servlet.jsp.tagext.SimpleTagSupport;
import java.io.IOException;

public class LoginFormTag extends SimpleTagSupport {

    private String action;


    @Override
    public void doTag() throws IOException {
        PageContext pageContext= (PageContext) getJspContext();
        JspWriter out=pageContext.getOut();

        HttpServletRequest request= (HttpServletRequest) pageContext.getRequest();


        out.print("<form action='"+request.getContextPath()+action+"' method='post'>");
        out.print(" 用户名：<input type='text' name='username'/><br/>");
        out.print(" 密码：<input type='password' name='password'/><br/>");
        out.print(" <input type='submit' value='登录'>");
        out.print("</form>");

        String message= (String) request.getAttribute("message");
        if(message!=null){
            out.print(message);
        }





    }

    public String getAction() {
        return action;
    }

    public void setAction(String action) {
        this.action = action;
    }
}
